package com.ruoyi.web.controller.admin.faq;

import com.ruoyi.admin.domain.LlmFaqCategory;
import com.ruoyi.admin.service.faq.LlmFaqCategoryService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/faq/category")
@RequiredArgsConstructor
public class LlmFaqCategoryController extends BaseController {

    private final LlmFaqCategoryService llmFaqCategoryService;


    /**
     * 新增
     */
    @PostMapping("/addFaqCategory")
    public AjaxResult addFaqCategory(@RequestBody LlmFaqCategory faq) {
        return llmFaqCategoryService.addFaqCategory(faq) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 修改
     */
    @PutMapping("/editFaqCategory")
    public AjaxResult editFaqCategory(@RequestBody LlmFaqCategory faq) {
        return llmFaqCategoryService.editFaqCategory(faq) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据ID删除
     */
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestParam("faqCategoryId") String faqCategoryId) {
        return llmFaqCategoryService.deleteLlmFaqCategory(faqCategoryId) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据ID查询
     */
    @GetMapping("/{id}")
    public LlmFaqCategory getById(@PathVariable String id) {
        return llmFaqCategoryService.getById(id);
    }

    /**
     * 查询所有
     */
    @GetMapping("/list")
    public TableDataInfo listAll() {
        startPage();
        return getDataTable(llmFaqCategoryService.list());
    }

    /**
     * 根据条件查询
     */
    @GetMapping("/getLlmFaqCategory")
    public List<LlmFaqCategory> getLlmFaqCategory(LlmFaqCategory faq) {
        return llmFaqCategoryService.getLlmFaqCategory(faq);
    }
}
